package priv.pront.code.mati.province;

import java.util.Scanner;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-11-15 16:49
 */
public class MC0142_矩阵计数 {

    static char[][] g;
    static int[][] dp;
    static int n;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        g = new char[n][n];
        dp = new int[n][n];
        for (int i = 0; i < n; i++) {
            g[i] = scanner.next().toCharArray();
        }

        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                if(g[i][j] == '0'){
                    dp[i][j] = dp[i - 1][j -1] + dp[i][j - 1] + dp[i - 1][j];
                } else if (g[i][j] == '1' && g[0][0] == '1' && g[i][0] == '1' && g[0][j] == '1') {
                    dp[i][j] = dp[i - 1][j -1] + dp[i][j - 1] + dp[i - 1][j] + 1;
                }
            }
        }
        System.out.println(dp[n - 1][n - 1]);
    }
}
